
#ifndef _MEMBER_BGRAPHICWIDGET_H_
#define _MEMBER_BGRAPHICWIDGET_H_

#include <BStyle>
#include <BMouseEvent>
#include <BGraphicItem>
#include <BGraphicWidget>

#define graphic_member(graphic)		((member_BGraphicWidget*)((BGraphicWidget*)graphic)->_ptr)

namespace BWE
{
	class member_BGraphicWidget
	{
		friend class BGraphicWidget;
	public:
		member_BGraphicWidget(BGraphicWidget* graphic);
		~member_BGraphicWidget();

		inline void emit(int signal, const BValue& value = BValue())
		{
			boss->emit(signal, value);
		}

		bool freshContents();
		void freshItem(BGraphicItem* item, const BEvent& event);
		void paintItem(BGraphicItem* item, BPainter& painter);
		BGraphicItem* locateItem(BPointf point, BGraphicItem* item);
		void collectVisualItems(BGraphicItem* item, const BPoint& offset, const BRect& crect);
		bool collectPrevItems(BGraphicItem* item, BGraphicItem* lastItem, BGraphicItemList& collectedItems);
		bool collectNextItems(BGraphicItem* item, BGraphicItem* lastItem, BGraphicItemList& collectedItems);

		BGraphicWidget*			boss;
		SelectMode				selectMode;
		BHolder<const BStyle>	itemStyle;

		bool					dirty;
		bool					pressed;
		BGraphicItem*			hoveredItem;
		BMouseEvent				mouseEvent;
		BEvent					styleEvent;
		BRectf					contentRect;

		BArray<BGraphicItemHolder>	items;
		BArray<BGraphicItem*>		selectedItems;
		BArray<BGraphicItem*>		visualItems;

	};
}

#endif
